﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAO;
namespace BUS
{
    public class SachBUS
    {
        SachDAO sDAO = new SachDAO();
        public object LayDSSach()
        {
            return sDAO.LayDSSach();
        }


        public object LayLoaiSach()
        {
            return sDAO.LayLoaiSach();
        }

        public  string ThemSach(SACH s)
        {
            if (s.TEN_SACH == "" || s.TAC_GIA == "" || s.NHA_XB == "" )
            {
                return "Ban chua nhap đu thong tin";
            }

            else
            {
                string kq = sDAO.ThemSach(s);

                if (kq == string.Empty)
                {
                    return "Them thanh cong.";
                }
                else
                {
                    return kq;
                }

            }
            return "";
            
        }

        public string ChinhSuaThongTinSach(SACH s)
        {
            if (s.TEN_SACH == "" || s.TAC_GIA == "" || s.NHA_XB == "")
            {
                return "Ban chua nhap đu thong tin";
            }

            else
            {
                string kq = sDAO.ChinhSuaThongTinSach(s);


                if (kq == string.Empty)
                {
                    return "Cap nhat thanh cong.";
                }
                else
                {
                    return kq;
                }

            }
            return "";
        }  

        public string XoaSach(SACH s)
        {
            return sDAO.XoaSach(s);
        }

        public string ThemLoaiSach(string tenloai)
        {
            if (tenloai == "")
            {
                return "Ban chua nhap đu thong tin";
            }

            else
            {
                string kq = sDAO.ThemLoaiSach(tenloai);

                if (kq == string.Empty)
                {
                    return "Them thanh cong.";
                }
                else
                {
                    return kq;
                }

            }
            return "";
            
        }

        public string XoaLoaiSach(int p)
        {
            return sDAO.XoaLoaiSach(p);
        }
    }
}
